<template>
  <el-container>
    <el-aside width="200px">
      <div class="home-title">个人理财财务</div>
      <div class="home-aside">
        <div
          class="home-aside__item"
          v-for="item in list"
          :key="item.index"
          @click="handerRouter(item)"
          :class="{ 'home-aside__item--show': item.show }"
        >
          <i :class="item.class"></i>
          <span>{{ item.name }}</span>
        </div>
      </div>
    </el-aside>
    <el-main>
      <div class="main-top">
        <div class="main-top__navber">{{ navberList.name }}</div>
        <div class="main-top__information">
          <i class="el-icon-user-solid"></i><span>main</span>
          <el-button type="primary" size="medium" plain @click="handerLogout">退出</el-button>
        </div>
      </div>
      <div class="main-content">
        <router-view></router-view>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import { getRecordList } from "@/api/1.js";
export default {
  data() {
    return {
      navberList: {
        name: "",
        show: true,
      },

      list: [
        {
          name: "首页",
          router: "/firstpage",
          class: "el-icon-suitcase",
          show: false,
        },
        {
          name: "支出",
          router: "/pay",
          class: "el-icon-notebook-1",
          show: false,
        },
        {
          name: "收入",
          router: "/income",
          class: "el-icon-collection",
          show: false,
        },
        {
          name: "类别分类",
          router: "/category",
          class: "el-icon-receiving",
          show: false,
        },
        {
          name: "个人信息",
          router: "/user",
          class: "el-icon-data-analysis",
          show: false,
        },
        {
          name: "设定目标",
          router: "/setgoals",
          class: "el-icon-notebook-2",
          show: false,
        },
        {
          name: "日常记录",
          router: "/records",
          class: "el-icon-edit",
          show: false,
        },
      ],
    };
  },
  created() {
    console.log(this.$route.path);
    this.list.forEach((element) => {
      element.show = false;
      if (element.router == this.$route.path) {
        element.show = true;
        this.navberList.name = element.name;
      }
    });
    getRecordList().then((res) => {
      console.log(res);
    });
  },

  methods: {
    handerRouter(item) {
      this.navberList.name = item.name;
      this.list.forEach((element) => {
        element.show = false;
      });
      item.show = true;
      this.$router.push(item.router);
    },
    handerLogout(){
        this.$router.push('/login')
    }
  },
};
</script>

<style scoped>
.el-container {
  background-color: #f2eff5;
  width: 100vw;
  min-height: 100vh;
  min-width: 1200px;
}
.home-title {
  font-weight: bold;
  color: #3689c0;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.home-aside__item {
  width: 100px;
  height: 100px;
  background-color: #fff;
  border-radius: 30px;
  color: #666;
  margin: 20px auto;
  cursor: pointer;
}
.home-aside__item--show {
  background-color: #3689c0;
  color: #fff;
}
.home-aside__item:hover {
  background-color: #3689c0;
  color: #fff;
}
.home-aside__item i {
  font-size: 30px;
  margin: 25px 30px 5px 35px;
}
.home-aside__item span {
  display: inline-block;
  width: 100%;
  text-align: center;
}
.main-top {
  width: 100%;
  height: 50px;
  position: relative;
  padding-top: 20px;
}

.main-top__navber {
  width: 200px;
  height: 50px;
  display: inline-block;
  background-color: #fff;
  color: #000;
  border-top-right-radius: 40px;
  border-top-left-radius: 10px;
  line-height: 60px;
  text-align: center;
  cursor: pointer;
}
.main-top__information {
  position: absolute;
  right: 20px;
  top: 20px;
  color: #3689c0;
  /* line-height: 30px; */
  font-size: 20px;
}
.main-top__information span {
  margin: 10px;
}
.main-content {
  width: 100%;
  min-height: calc(100% - 70px);
  background-color: #fff;
  border-radius: 10px;
  border-top-left-radius: 0px;
}
</style>